﻿using System;
using Microsoft.Phone.Controls;

namespace TourGuideApp
{
    public partial class ToursListPage : PhoneApplicationPage
    {
        public ToursListPage()
        {
            InitializeComponent();
        }

        private void ListBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            //Do nothing if there is no selection
            if (toursListBox.SelectedIndex == -1)
                return;
            App.tourIndex = toursListBox.SelectedIndex;
            App.stopIndex = -1;
            //Navigate to details page and inform the selection
            NavigationService.Navigate(new Uri("/TourDetailsPage.xaml", UriKind.Relative));
            //Reset to no selection
            toursListBox.SelectedIndex = -1;
        }
    }
}
